package com.dkt.doctor;

import com.dkt.common.CommonResponse;
import com.dkt.common.SysConst;
import com.dkt.common.SysException;
import com.dkt.org.OrgListBean;
import com.dkt.org.OrgRequestBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by litai on 2017/6/17.
 */
@RestController
@Scope("session")
public class DoctorController {

    private static final Logger log = LoggerFactory.getLogger(DoctorController.class);

    @Autowired
    private DoctorService service;

    @RequestMapping("/external/tlm/getDoctors")
    public CommonResponse<List<DoctorListBeanP10012>> getListUser(@RequestBody RequestBeanP10012 request) {

        CommonResponse<List<DoctorListBeanP10012>> wr = new CommonResponse<List<DoctorListBeanP10012>>();
        log.debug("开始获取机构医生信息");
        try {

            List<DoctorListBeanP10012> list = service.getList(request);
            wr.setResult(list);

        } catch (SysException e) {

            wr.setStatus(SysConst.STATUS_ERROR);
            wr.setErrorCode(e.getCode());
            wr.setErrorMsg(e.getError());
        }
        return wr;
    }

    @RequestMapping("/external/tlm/getDoctorInfo")
    public CommonResponse<DoctorBeanP10013> getListUser(@RequestBody RequestBeanP10013 request) {

        CommonResponse<DoctorBeanP10013> wr = new CommonResponse<DoctorBeanP10013>();
        log.debug("开始获取机构医生详细信息");
        try {

            DoctorBeanP10013 db = service.getDoctorDetail(request);
            wr.setResult(db);

        } catch (SysException e) {
            wr.setStatus(SysConst.STATUS_ERROR);
            wr.setErrorCode(e.getCode());
            wr.setErrorMsg(e.getError());
        }
        return wr;
    }
}
